<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/layui/layui/css/layui.css}" rel="stylesheet"  media="all"/>
<style>
        .layui-tab{ border-width: 1px; border-style: solid;border-color:#ddd}
    </style>
<body class="gray-bg">
	<div class="container-div ui-layout-center">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="hc-form">
					<div class="select-list">
						<ul>
							<li>
								考核单元：
								<select id="checkPdu"  name="checkPdu"  style="width: 100px" th:with="type=${@dict.getType('check_unit')}">
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
								</select>
							</li>
							<li>
								PDU：
								<select id="pdu"  name="pdu"  style="width: 100px" th:with="type=${@dict.getType('human_pdu')}">
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
								</select>
							</li>
							<li>
								地域：
								<select id="region"  name="region"  style="width: 100px" th:with="type=${@dict.getType('check_region')}">
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
								</select>
							</li>

							<li>
								月份：
								<select id="month"  name="month"  style="width: 100px" th:with="type=${@dict.getType('data_month')}">
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
								</select>
							</li>
							<li>
								PO编号：
								<input type="text" style="width: 120px" name="po" id="po"/>
							</li>
							<li>
								<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-success btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>

			</div>
			<div class="layui-tab layui-tab-brief" style="margin:80px 0px 0px 0px;" lay-filter="test1">
				<ul class="layui-tab-title" style="padding:0px">
					<li class="layui-this">加班超8小时</li>
					<li>月工时不足周末加班</li>
					<li>月度工时不足8小时</li>
					<li>周末加班不足8小时</li>
					<li>周末加班工时异常处理</li>
					<li>月度请假3天及以上</li>
					<li>晚上疑似补打卡</li>
					<li>月末疑似补打卡</li>

				</ul>
				<div class="layui-tab-content" style="padding:0px 2px 0px 2px">
					<table class="table table-hover" id="bootstrap-table" data-mobile-responsive="true"></table>
				</div>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
	<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
	<script th:src="@{/ajax/libs/layui/layui/layui.js}"></script>

	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('worktime:data:edit')}]];
		var removeFlag = [[${@permission.hasPermi('worktime:data:remove')}]];
		var regions = [[${@dict.getType('check_region')}]];
		var pdus = [[${@dict.getType('human_pdu')}]];
		var prefix = ctx + "worktime/data";

		$(function() {
			$('body').layout({ west__size: 185 });
			initTable(0);
		});

		layui.use('element', function(){
		  var element = layui.element;
		  element.on('tab(test1)', function(data){
			initTable(data.index);
		  });
		});

		function initTable(analysisType){
			$("#bootstrap-table").bootstrapTable('destroy');
			if(analysisType ==0){
				queryExtraGreater8Hours();
			}else if(analysisType ==1){
				queryLackHasExtra();
			}else if(analysisType ==2){
				queryLackWorktime();
			}else if(analysisType ==3){
				queryExtraLess8Hours();
			}else if(analysisType ==4){
				queryHasDoubleFlows();
			}else if(analysisType ==5){
				queryGreater3TimesLeave();
			}else if(analysisType ==6){
				//疑似补打卡
				queryDoubtRepairWorktime();
			}else if(analysisType ==7){
				//月末疑似补打卡
				queryMonthOweWorktime();
			}
		}
		function queryMonthOweWorktime(){
				var options = {
				url: prefix + "/list/queryMonthOweWorktime",
				updateUrl: prefix + "/edit/{id}",
				modalName: "修改",
				search: false,showExport: false,showColumns: false,
				showRefresh: false,showToggle: false,showHeader: false,
				showFooter: false,searchable: false,smartDisplay:false,
				showSearch:false,
				queryParams:queryParams,
				columns: [
				{checkbox: true},
				{
		            title: '操作',
		            align: 'center',
		            width:"70",
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		                return actions.join('');
		            }
		        },
				{field: 'id',title: '外包编号'},
				{field: 'hwCode',title: '华为工号'},
				{field: 'name',title: '姓名'},
				{field: 'poNum',title: 'PO编号'},
				{field: 'signinDate',title: '打卡日期',cellStyle: formatTableUnit,formatter: paramsMatter},
				{field: 'signinTime',title: '打卡时间',cellStyle: formatTableUnit,formatter: paramsMatter},
				{field: 'avgFirstHalfMonthHours',title: '前20天平均工时'},
				{field: 'avgLastHalfMonthHours',title: '后10天平均工时'},
				{field: 'month',title: '月份'},
				{field: 'pdu',title: 'PDU'},
				{field: 'region',title: '地域'},
				]
			};
			$.table.init(options);
		}

		function queryDoubtRepairWorktime(){
				var options = {
				url: prefix + "/list/queryDoubtRepairWorktime",
				modalName: "PO",
				search: false,showExport: false,showColumns: false,
				showRefresh: false,showToggle: false,showHeader: false,
				showFooter: false,searchable: false,smartDisplay:false,
				showSearch:false,
				queryParams:queryParams,

				columns: [
				{checkbox: true},
				{
		            title: '操作',
		            align: 'center',
		            width:"70",
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.hcId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		                return actions.join('');
		            }
		        },
				{field: 'id',title: '外包编号'},
				{field: 'hwCode',title: '华为工号'},
				{field: 'name',title: '姓名'},
				{field: 'poNum',title: 'PO编号'},
				{field: 'signinDate',title: '打卡日期',
		            formatter: function(value, row, index) {
		            	var checkdate = value.substring(0,10);
		            	return "<p>"+checkdate+"</p>";
		            }},
				{field: 'signinTime',title: '打卡时间'},
				{field: 'hours',title: '打卡间隔大于1小时'},
				{field: 'month',title: '月份'},
				{field: 'pdu',title: 'PDU'},
				{field: 'region',title: '地域'},
				]
			};
			$.table.init(options);
		}
		function queryGreater3TimesLeave() {
			var options = {
				url: prefix + "/list/queryGreater3TimesLeave",
				modalName: "PO",
				search: false,showExport: false,showColumns: false,
				showRefresh: false,showToggle: false,showHeader: false,
				showFooter: false,searchable: false,smartDisplay:false,
				showSearch:false,
				queryParams:queryParams,
				columns: [
				{checkbox: true},
				{field: 'id',title: '外包编号'},
				{field: 'hwCode',title: '华为工号'},
				{field: 'name',title: '姓名'},
				{field: 'poNum',title: 'PO编号'},
				{field: 'leaveDate',title: '请假日期',
		            formatter: function(value, row, index) {
		            	var checkdate = value.substring(0,10);
		            	return "<p>"+checkdate+"</p>";
		            }},
				{field: 'leaveStartTime',title: '请假开始日期'},
				{field: 'leaveEndTime',title: '请假结束日期'},
				{field: 'leaveFlowNo',title: '请假流水号'},
				{field: 'pdu',title: 'PDU'},
				{field: 'region',title: '地域'},
				]
			};
			$.table.init(options);
		}


		function queryHasDoubleFlows() {
			var options = {
				url: prefix + "/list/queryHasDoubleFlows",
				modalName: "PO",
				search: false,showExport: false,showColumns: false,
				showRefresh: false,showToggle: false,showHeader: false,
				showFooter: false,searchable: false,smartDisplay:false,
				showSearch:false,
				queryParams:queryParams,
				columns: [
				{checkbox: true},
				{field: 'hwCode',title: '华为工号'},
				{field: 'name',title: '姓名'},
				{field: 'po',title: 'PO编号'},
				{field: 'checkDate',title: '日期',
		            formatter: function(value, row, index) {
		            	var checkdate = value.substring(0,10);
		            	return "<p>"+checkdate+"</p>";
		            }
				},
				{title: '存在多个电子流',
				formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<p>是</p>');
						return actions.join('');
		            }},
				{field: 'hwPM',title: '华为PM'},
				{field: 'pdu',title: 'PDU'},
				{field: 'region',title: '地域'},

				]
			};
			$.table.init(options);
		}

		function queryExtraLess8Hours() {
			var options = {
				url: prefix + "/list/queryExtraLess8Hours",
				modalName: "PO",
				search: false,showExport: false,showColumns: false,
				showRefresh: false,showToggle: false,showHeader: false,
				showFooter: false,searchable: false,smartDisplay:false,
				showSearch:false,
				queryParams:queryParams,
				columns: [
				{checkbox: true},
				{field: 'hwCode',title: '华为工号'},
				{field: 'name',title: '姓名'},
				{field: 'po',title: 'PO编号'},
				{field: 'extraHours',title: '加班时长'},
				{field: 'hwPM',title: '华为PM'},
				{field: 'pdu',title: 'PDU'},
				{field: 'region',title: '地域'}
				]
			};
			$.table.init(options);
		}

	 	//表格超出宽度鼠标悬停显示td内容
		function paramsMatter(value, row, index) {
			var span = document.createElement("span");
			span.setAttribute("title", value);
			span.innerHTML = value;
			return span.outerHTML;
		}
		//td宽度以及内容超过宽度隐藏
		function formatTableUnit(value, row, index) {
			return {
				css: {
					"white-space": "nowrap",
					"text-overflow": "ellipsis",
					"overflow": "hidden",
					"max-width": "60px"
				}
			}
		}

		function queryParams(params){
			var checkPdu =  $("#checkPdu option:selected").val();
			var pdu = $("#pdu option:selected").val();
			var region = $("#region option:selected").val();
			var month = $("#month option:selected").val();
			var po =  $("input[name='po']").val();
			return  {
				checkPdu:checkPdu,
				pdu :pdu,
				region :region,
				month :month,
				po:po,
				pageSize:       params.limit,
				pageNum:        params.offset / params.limit + 1,
				searchValue:    params.search,
				orderByColumn:  params.sort,
				isAsc:          params.order
			 };
		}
		function queryLackWorktime() {
			var options = {
				url: prefix + "/list/queryLackWorktime",
				modalName: "PO",
				search: false,showExport: false,showColumns: false,
				showRefresh: false,showToggle: false,showHeader: false,
				showFooter: false,searchable: false,smartDisplay:false,
				showSearch:false,
				queryParams:queryParams,
				columns: [
				{checkbox: true},
				{field: 'po',title: 'PO编号'},
				{field: 'name',title: '姓名'},
				{field: 'month', title: '月份'},
				{field: 'oweServiceHours',title: '欠工时'},
				{field: 'minServiceHours',title: '最低服务工时'},
				{field: 'actualServiceHours',title: '实际打卡工时'},
				{field: 'hwPm',title: '华为PM'},
				{field: 'pdu',title: 'PDU'},
				{field: 'region',title: '地域'}
				]
			};
			$.table.init(options);
		}
		function queryLackHasExtra() {
					var options = {
						url: prefix + "/list/queryLackHasExtra",
						modalName: "PO",
						search: false,showExport: false,showColumns: false,
						showRefresh: false,showToggle: false,showHeader: false,
						showFooter: false,searchable: false,smartDisplay:false,
						showSearch:false,
						queryParams:queryParams,
						columns: [
						{checkbox: true},

						{field: 'name',title: '姓名'},
						{field: 'id',title: '外包编号'},
						{field: 'po',title: 'PO编号'},
						{field: 'month', title: '月份'},
						{field: 'oweServiceHours',title: '欠工时'},
						{field: 'extraHours',title: '加班工时'},
						{field: 'minServiceHours',title: '最低服务工时'},
						{field: 'actualServiceHours',title: '实际打卡工时'},
						{field: 'hwPm',title: '华为PM'},
						{field: 'pdu',title: 'PDU'},
						{field: 'region',title: '地域'}
						]
					};
					$.table.init(options);
				}

		function queryExtraGreater8Hours() {
		    var options = {
		        url: prefix + "/list/queryExtraGreater8Hours",
		        modalName: "PO",
		        search: false,showExport: false,showColumns: false,
		        showRefresh: false,showToggle: false,showHeader: false,
		        showFooter: false,searchable: false,smartDisplay:false,
		        showSearch:false,
		        queryParams:queryParams,
		        columns: [
		        {checkbox: true},
		        {field: 'hwCode',title: '华为工号'},
		        {field: 'name',title: '姓名'},
		        {field: 'checkDate',title: '日期',
		            formatter: function(value, row, index) {
		            	var checkdate = value.substring(0,10);
		            	return "<p>"+checkdate+"</p>";
		            }},
		        {field: 'po',title: 'PO编号'},
		        {field: 'extraHours',title: '加班时长'},
		        {field: 'hwPM',title: '华为PM'},
		        {field: 'pdu',title: 'PDU'},
		        {field: 'region',title: '地域'}
		        ]
		    };
		    $.table.init(options);
		}

		//表格超出宽度鼠标悬停显示td内容
		function paramsMatter(value, row, index) {
			var span = document.createElement("span");
			span.setAttribute("title", value);
			span.innerHTML = value;
			return span.outerHTML;
		}
		//td宽度以及内容超过宽度隐藏
		function formatTableUnit(value, row, index) {
			return {
				css: {
					"white-space": "nowrap",
					"text-overflow": "ellipsis",
					"overflow": "hidden",
					"max-width": "60px"
				}
			}
		}
	</script>
</body>
</html>